package com.example.newncee.ui.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.newncee.R;
import com.example.newncee.ui.adapter.SchoolListAdapter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Sora
 * time: 2022/2/11 23:24
 * description: school list
 */
public class HomeFragment extends Fragment {

    private List<String> data=new ArrayList<>();

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {

        View root = inflater.inflate(R.layout.fragment_home, container, false);
        RecyclerView mRecyclerView = (RecyclerView) root.findViewById(R.id.recyclerView);

        initData();
        SchoolListAdapter schoolListAdapter = new SchoolListAdapter(data);
        mRecyclerView.setAdapter(schoolListAdapter);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this.getContext()));

        return root;
    }
    private void initData(){
        String[] stringArray = getResources().getStringArray(R.array.schools);
        Collections.addAll(data, stringArray);
    }

}